package com.sptpc.stu.model;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;

/**
 * 课程的实体类
 */
@Entity
@Table(name = "t_course")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Course implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String cid;
    private String name;
    private Integer courseTime;
    private Integer coursePoints;
    private String demo;

    /**
     * 实现双向的多对多关系:被控制方
     * mappedBy：关联的控制方的实体类的属性名
     */
    @ManyToMany(mappedBy = "courses")
    @JsonIgnore
    private List<Student> students;
}
